#include "RTPSharePicture.hpp"
#include "SharedMemory.hpp"

#include "RTPSharePictureImpl.hpp"

namespace Hi {
	
static void on_pic(const uint8_t* data, uint32_t width, uint32_t height) {
}
RTPSharePicture::RTPSharePicture() {
	this->impl = new RTPSharePictureImpl();
	this->on_rbg = on_pic;
	this->on_yuv = on_pic;
}

RTPSharePicture::~RTPSharePicture() {
	if (nullptr == this->impl) {
		return;
	}
	this->Stop();
	delete this->impl;
	this->impl = nullptr;
}

bool RTPSharePicture::Start(const char* sharePath, uint32_t width, uint32_t height) {
	if (nullptr == this->impl) {
		return false;
	}
	return this->impl->Start(sharePath, width, height);
	
}
void RTPSharePicture::Stop() {
	if (nullptr == this->impl) {
		return;
	}
	this->impl->Stop();
}

void RTPSharePicture::OnYUV(const uint8_t* data, size_t len, uint32_t width, uint32_t height, void* opt) {
	if (nullptr == this->impl) {
		return;
	}
	this->impl->OnYUV(data, len, width, height, opt);
	this->on_yuv(data, width, height);
}
void RTPSharePicture::OnRGB(const uint8_t* data, size_t len, uint32_t width, uint32_t height, void* opt) {
	if (nullptr == this->impl) {
		return;
	}
	this->impl->OnRGB(data, len, width, height, opt);
	this->on_rbg(data, width, height);
}
void  RTPSharePicture::SetCallback(const PIC_CALLBACK& onrgb, const PIC_CALLBACK& onyuv) {
	this->on_rbg = onrgb;
	this->on_yuv = onyuv;
}
}